/**
 * 
 */
package com.shy.base.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.shy.base.util.VerifyImgUtil;

/**
 * <p>Title:VerifyController </p>
 * <p>Description: </p>
 * <p>Company:ipebg </p> 
 * @author shanhanyu
 * @date 2019年8月8日
 */
@Controller
public class VerifyImgController {

	/**
	 * 图形验证码生成
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author shanhanyu
	 * @date 2019年8月8日
	 */
	@RequestMapping("/verifyImg")
	public void createImg(HttpServletRequest request, HttpServletResponse response) throws Exception {
	    try {
	        response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
	        response.setHeader("Pragma", "No-cache");//设置响应头信息，告诉浏览器不要缓存此内容
	        response.setHeader("Cache-Control", "no-cache");
	        response.setDateHeader("Expire", 0);
	        VerifyImgUtil randomValidateCode = new VerifyImgUtil();
	        randomValidateCode.getRandcode(request, response);//输出验证码图片
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	
}
